package org.darkforest.common.services.impl;

import org.darkforest.common.services.OrderLogService;
import org.darkforest.dao.mapper.OrderLogMapper;
import org.darkforest.model.OrderLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Libing on 2015/6/27.
 */
@Service
public class OrderLogServiceImpl implements OrderLogService {


    @Autowired
    private OrderLogMapper orderLogMapper;

    /**
     * 订单状态变更时需要记录订单的在变更之前的状态
     *
     * @param orderLog
     */
    @Override
    public void AddOrderLog(OrderLog orderLog) {

        orderLogMapper.insert(orderLog);
    }

    @Override
    public void CancleUnpayOrderForLog(String sbd) {
        Map<String,String> map = new HashMap<String,String>();
        map.put("sql",sbd);
        orderLogMapper.addDataBySql(map);
    }

    @Override
    public int deleteByPrimaryKey(Integer logId) {
        return orderLogMapper.deleteByPrimaryKey(logId);
    }

    @Override
    public int insert(OrderLog record) {
        return orderLogMapper.insert(record);
    }

    @Override
    public int insertSelective(OrderLog record) {
        return orderLogMapper.insertSelective(record);
    }

    @Override
    public OrderLog selectByPrimaryKey(Integer logId) {
        return orderLogMapper.selectByPrimaryKey(logId);
    }

    @Override
    public int updateByPrimaryKeySelective(OrderLog record) {
        return orderLogMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(OrderLog record) {
        return orderLogMapper.updateByPrimaryKey(record);
    }

    @Override
    public List<OrderLog> selectByOrderId(Integer id) {
        return orderLogMapper.selectByOrderId(id);
    }

    @Override
    public void addDataBySql(Map<String, String> map) {
        orderLogMapper.addDataBySql(map);
    }
}
